﻿using SuperX.Common.Collection;
using SuperX.Common.APIManager;
using SuperX.Common.Scheduler;
using SuperX.Common.MSG;
using SuperX.Common.PlugIn;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using SuperX.Common.Code;

namespace SuperX.Common
{
    //
    public interface IProject : IObjCollection, IBasicObject, IJsonSerialize, INotifyPropertyChanged, IDisposable, ICloneable, ICollectionNotify, IController, IPersistence
    {
        IMsgCache MsgCache { get; }

        /// <summary>
        /// 工程目录
        /// </summary>
        string ProjectDir { get; }

        /// <summary>
        /// 工程全路径
        /// </summary>
        string ProjectFullPath { get; }

        /// <summary>
        /// Server实例
        /// </summary>
        IProjService Server { get; }

        /// <summary>
        /// 工程状态
        /// </summary>
        ProjectState State { get; }

        //
        event EventHandler<ProjectActionEventArgs> ProjectAction;

        /// <summary>
        /// 是否正在加载工程
        /// </summary>
        bool IsLoading { get; }

        //
        DateTime StartTime { get; }

        //
        SchedulerManager SchedulerManager { get; }

        /// <summary>
        /// IoT全局对象
        /// </summary>
        ConcurrentDictionary<string, IBasicObject> Objects { get; }

        //
        ConcurrentDictionary<string, List<IBasicObject>> CacheObjects { get; }

        //
        IReference References { get; set; }

        //
        Dictionary<string, IAPIController> APIControllers { get; }

        /// <summary>
        /// Project的插件集合
        /// </summary>
        ObjectCollection<IProject, IPlugIns> PlugIns { get; set; }

        //
        ProjectInfo ProjectInfo { get; set; }

        CodeObject CodeObject { get; set; }

        CodeManager CodeManager { get; set; }

        ICode CreateEngine(string engineName, IDictionary<string, object> variables, string engineType = "Python");

        //
        void FireEventChanged(IBasicObject baseObject, string source, Type dataType = null, string fullName = null);

        List<ModuleInfo> LoadLocalService();
    }
}